﻿using System.Windows;

namespace Gmantis.Controls.Chart
{
    public class PieSlice : Pie
    {
        // Fields
        public static readonly DependencyProperty OffsetProperty = DependencyProperty.Register("Offset", typeof(double), typeof(PieSlice), new PropertyMetadata(0.0, new PropertyChangedCallback(PieSlice.OnOffsetChanged)));

        // Methods
        internal override object Clone()
        {
            PieSlice clone = new PieSlice();
            base.CloneAttributes(clone);
            return clone;
        }

        private static void OnOffsetChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            PieSlice slice = (PieSlice)obj;
            slice._pi.Offset = slice.Offset;
            slice.UpdateOffset();
        }

        protected override bool Render(RenderContext rc)
        {
            return base.Render(rc);
        }

        // Properties
        public double Angle
        {
            get
            {
                return (this._pi.Angle + (0.5 * this._pi.Sweep));
            }
        }

        public double Offset
        {
            get
            {
                return (double)base.GetValue(OffsetProperty);
            }
            set
            {
                base.SetValue(OffsetProperty, value);
            }
        }

        public Point PieCenter
        {
            get
            {
                return this._pi.Center;
            }
        }
    }
}
